
import { IsString, IsNumber, IsBoolean, IsDate, IsOptional, IsEnum } from 'class-validator';
import { ApiProperty, OmitType, IntersectionType } from '@nestjs/swagger';
import { PagingDto } from 'src/common/dto/index';
import { CharEnum } from 'src/common/enum/index';


export class BaseIssueDto{
    @ApiProperty({required: false , description: '问题ID'})
    @IsOptional()
    @IsNumber()
    issueId?: number;

    @ApiProperty({enum: CharEnum, required: false , description: '删除标志'})
    @IsOptional()
    @IsString()
    delFlag?: string;

    @ApiProperty({enum: CharEnum, required: false , description: '状态'})
    @IsOptional()
    @IsString()
    status?: string;

    @ApiProperty({required: false , description: '创建者'})
    @IsOptional()
    @IsString()
    createBy?: string;

    @ApiProperty({required: false , description: '创建时间'})
    @IsOptional()
    @IsString()
    createTime?: string;

    @ApiProperty({required: false , description: '更新者'})
    @IsOptional()
    @IsString()
    updateBy?: string;

    @ApiProperty({required: false , description: '更新时间'})
    @IsOptional()
    @IsString()
    updateTime?: string;

    @ApiProperty({required: false , description: '备注'})
    @IsOptional()
    @IsString()
    remark?: string;

    @ApiProperty({required: false , description: '标题'})
    @IsOptional()
    @IsString()
    title?: string;

    @ApiProperty({required: false , description: '副标题'})
    @IsOptional()
    @IsString()
    subTitle?: string;

    @ApiProperty({required: false , description: '关键字'})
    @IsOptional()
    @IsString()
    keyword?: string;

    @ApiProperty({required: false , description: '是否加入题库'})
    @IsOptional()
    @IsString()
    inStore?: string;

    @ApiProperty({required: false , description: '字段键名'})
    @IsOptional()
    @IsString()
    field?: string;

    @ApiProperty({required: false , description: '题目类型'})
    @IsOptional()
    @IsString()
    type?: string;

    @ApiProperty({required: false , description: '选项信息'})
    @IsOptional()
    options?: any;

    @ApiProperty({required: false , description: '题目标签'})
    @IsOptional()
    @IsString()
    tag?: string;

    @ApiProperty({required: false , description: '是否必答'})
    @IsOptional()
    @IsString()
    isRequired?: string;


    @ApiProperty({required: false , description: '正确答案'})
    @IsOptional()
    @IsString()
    answer?: string;

    @ApiProperty({required: false , description: '是否为主观题'})
    @IsOptional()
    @IsString()
    isSubjective?: string;

    @ApiProperty({required: false , description: '验证数据'})
    @IsOptional()
    validateArr?: any;

}

export class CreateIssueDto extends OmitType(BaseIssueDto, [ 'delFlag', 'createBy', 'createTime']){
    @ApiProperty({required: false , description: '题目分数'})
    @IsOptional()
    score?: number;
}

export class UpdateIssueDto extends OmitType(BaseIssueDto, [ 'delFlag', 'createBy', 'createTime']){}

export class QueryIssueDto extends IntersectionType( BaseIssueDto, PagingDto){}

export class ListIssueDto  extends OmitType(BaseIssueDto, [ 'delFlag', 'createBy', 'createTime', 'updateBy', 'updateTime']) {}
